
package core {
import flash.display.DisplayObject;

import mx.utils.object_proxy;

public class MovingObject extends AGameObject {
    private var _minX:int;
    private var _minY:int;
    private var _maxX:int;
    private var _maxY:int;
    private var _speedX:Number;
    private var _speedY:Number;
    private var _obj:DisplayObject;
    public function MovingObject(obj:DisplayObject) {
        _obj = obj;
        addChild(_obj);
        this.mouseEnabled = false;
        this.mouseChildren = false;
    }
    public function setPos(p_x:int, p_y:int):void{
        _obj.x = p_x;
        _obj.y = p_y;
    }

    public function setBounds(minX:int, minY:int, maxX:int, maxY:int):void{
        _minX = minX;
        _minY = minY;
        _maxX = maxX;
        _maxY = maxY;
    }

    public function setSpeed(p_x:Number, p_y:Number):void{
        _speedX = p_x;
        _speedY = p_y;
    }

    override public function update():void
    {
        _obj.x +=_speedX+0.0;
        _obj.y +=_speedY+0.0;

        if (_obj.x > _maxX) _obj.x = _minX;
        if (_obj.x < _minX) _obj.x = _maxX;

        if (_obj.y > _maxY) _obj.y = _minY;
        if (_obj.y < _minY) _obj.y = _maxY;

    }

}
}
